﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace _18自引用的组织结构树;

public class OrgUnitConfig:IEntityTypeConfiguration<OrgUnit>
{
    public void Configure(EntityTypeBuilder<OrgUnit> builder)
    {
        builder.ToTable("T_OrgUnit");
        builder.Property(o => o.Name).IsUnicode().HasMaxLength(50).IsRequired();
        builder.HasOne<OrgUnit>(o => o.Parent).WithMany(o => o.Children).OnDelete(DeleteBehavior.NoAction).IsRequired(false);
    }
}